#ifndef JSHANDLER_H
#define JSHANDLER_H

#include <QObject>
#include <QJsonObject>
#include <QJsonDocument>
#include <QHash>
#include <QDebug>
class JSHandler : public QObject
{
    Q_OBJECT
public:
    static JSHandler* getInstance();
    void handle(const QJsonDocument& doc);

private slots:
    void analysisMessage(const QJsonObject& rootobj);
    void analysisRespond(const QJsonObject& rootobj);
    void dealSignup(const QString& status);
    void dealLogin(const QString& status);
    void fileReady(const QJsonObject &rootobj);
    void analysisScfilehead(const QJsonObject &rootobj);
    void fileEnd(const QJsonObject &rootobj);
signals:
    void s_haveNewMessage(QPair<QString,QString> mes);
    void s_signUpPass();
    void s_signUpError();
    void s_logInPass();
    void s_logInError();
    void s_logInBan();
    void s_fileReady();
    void s_recvFileHead(const QString& senderoc,const unsigned long filesize,const QString& filesha256,const QString& filename);
    void s_fileEnd();
private:
    JSHandler();

    static JSHandler* parser;
    static QHash<QString, QByteArray> handlers;
    static QHash<QString, QByteArray> respondhash;

};

#endif // CLASSIFICATIONPARSER_H
